/**
 * WhiMAIcpp - C++ interface for the Whiskey Media APIs.
 *  Copyright (C) 2010  Anders Bugge
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "search.h"

namespace WM
{

namespace GB
{

Search::Search() : List( "search" )
{
	resource = "";
	setQuery( query );
}

Search::Search( std::string query, unsigned int offset, unsigned int limit, bool* ok ) : List( "search" )
{
	resource = "";
	setQuery( query );
	update( offset, limit, ok );
}

Search::~Search()
{
}

void Search::setQuery( std::string value )
{
	query = value;
	updateExtraUrl();
}

void Search::setResources( std::string value )
{
	resource = value;
	updateExtraUrl();
}

void Search::updateExtraUrl()
{
	URL_EXTRA = "&query=" + query;
	if( !resource.empty() )
		URL_EXTRA += "&resources=" + resource;
}

}

namespace CV
{

Search::Search() : List( "search" )
{
	resource = "";
	setQuery( query );
}

Search::Search( std::string query, unsigned int offset, unsigned int limit, bool* ok ) : List( "search" )
{
	resource = "";
	setQuery( query );
	update( offset, limit, ok );
}

Search::~Search()
{
}

void Search::setQuery( std::string value )
{
	query = value;
	updateExtraUrl();
}

void Search::setResources( std::string value )
{
	resource = value;
	updateExtraUrl();
}

void Search::updateExtraUrl()
{
	URL_EXTRA = "&query=" + query;
	if( !resource.empty() )
		URL_EXTRA += "&resources=" + resource;
}

}


}
